package com.talentech.xproberlib;

import java.util.LinkedList;
import java.util.List;

import android.app.Activity;
import static com.talentech.xproberlib.Utils.*;

public class Memory
{
	//单实例相关--------------------------------------------------
	static Memory mMemory;

	public static Memory getInstance()
	{
		if (mMemory == null)
		{
			mMemory = new Memory();
		}
		return mMemory;
	}
	
	//以下为正常部分----------------------------------------------
	protected static List<Activity> activityList = new LinkedList<Activity>();
	
	/**
	 * @return -1 if error
	 * */
	
	public static int getActivityId(Activity activity)
	{
		if(activity == null)
		{
			log("getId: null object");
			return -1;
		}
		
		int index = activityList.indexOf(activity);
		
		if(index < 0)
		{
			activityList.add(activity);
			index = activityList.indexOf(activity);
		}
		
		return index;
	}
}
